package love.yuanmeng.guetcoalsystem.cotroller;

/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:HuangHongTao
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/10/14 20:55
 */

import love.yuanmeng.guetcoalsystem.pojo.User;
import love.yuanmeng.guetcoalsystem.service.LoginService;
import love.yuanmeng.guetcoalsystem.util.DataGridView;
import love.yuanmeng.guetcoalsystem.util.ResultObj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@CrossOrigin
@Controller
@RequestMapping("login")
public class LoginController {
    @Autowired
    LoginService loginService;

    @ResponseBody
    @RequestMapping("login")
    public DataGridView login(@RequestBody User user) {
        try {
            return loginService.login(user);
        } catch (Exception e) {
            return new DataGridView(-1, null);
        }


    }

}
